import fetch from "../assets/js/fetch"
export default {
  state:{
    productTypes:[]
  },
  mutations:{
      setProductType(state,data){
          state.productTypes=data
          // console.log(state.productTypes)
      }
  },
  actions: {
      //获取商品类型列表
      async getProductTypes({commit}){
        let data=await fetch.get("/api/product_types?offset=&limit=99999")
        commit("setProductType",data.data)
      },
      //添加商品类型
      async postProductType({commit},stark){
        await fetch.post("/api/product_types",stark)
      },
      //编辑商品类型信息
      async editProductType({commit},stark){
        await fetch.put("/api/product_types/"+stark.productsTypeId,stark.products_type_form)
      },
      // //删除商品类型信息
      // async deleteProductType({commit},stark){
      //     await fetch.delete("/api/product_types/"+stark.productsTypeId)
      // }
  }
}